home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / phigs / ptk.lha / ptk / source / library / misc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-01  |  21.3 KB  |  750 lines

  1. /*----------------------------------------------------------------------------
  2.  
  3.   Module name: Miscellaneous
  4.  
  5.   Author: Gareth Williams.
  6.  
  7.   Function: module containing PHIGS functions which work for both DEC PHIGS
  8.    and SunPHIGS. Also functions which use Ppoint datatypes instead of
  9.    Pvec.
  10.  
  11.   Dependencies:
  12.  
  13.   Internal function list: 
  14.  
  15.   External function list: 
  16.  
  17.   Hashtables used: none.
  18.  
  19.   Modification history: (Version), (Date), (name), (Description).
  20.  
  21.   1.0, 5th September 1991, G. Williams, First version.
  22.  
  23.   2.0, June 1992, G. Williams, Converted to ISO PHIGS C.
  24.  
  25. ----------------------------------------------------------------------------*/
  26.  
  27. #include <stdio.h>
  28. #include <ctype.h>
  29. #include <math.h>
  30. #include <phigs.h>
  31. #include "ptk.h"
  32.  
  33. /*--------------------------------------------------------------------------*/
  34.  
  35. /*function:external*/
  36. extern void ptk_delstore(C(Pstore) store)
  37. PreANSI(Pstore store)
  38. /*
  39. ** \parambegin
  40. ** \param{Pstore}{store}{number of point sets}{IN}
  41. ** \paramend 
  42. ** \blurb{This function calls DELETE STORE for SunPHIGS and does nothing
  43. ** for HP PHIGS.}
  44. */
  45. {
  46.   /* if HP then don't call since it causes a crash */
  47. #ifndef HP
  48.   /* do for SUN and PEXSI */
  49.   pdel_store(store);
  50. #endif
  51. }  /* ptk_delstore */
  52.  
  53. /*--------------------------------------------------------------------------*/
  54.  
  55. /*function:external*/
  56. extern void ptk_fillareaset(C(Pint) numsets, C(Ppoint_list *) sets)
  57. PreANSI(Pint numsets)
  58. PreANSI(Ppoint_list *sets)
  59. /*
  60. ** \parambegin
  61. ** \param{Pint}{numsets}{number of point sets}{IN}
  62. ** \param{Ppoint\_list *}{sets}{list of point sets}{IN}
  63. ** \paramend 
  64. ** \blurb{This function creates a FILL AREA SET output primitive
  65. ** and works for both SunPHIGS and DEC PHIGS.}
  66. */
  67. {
  68.   Ppoint_list_list ptlist;
  69.  
  70.   ptlist.num_point_lists = numsets;
  71.   ptlist.point_lists = sets;
  72.   pfill_area_set(&ptlist);
  73. }  /* ptk_fillareaset */
  74.  
  75. /*--------------------------------------------------------------------------*/
  76.  
  77. /*function:external*/
  78. extern void ptk_fillareaset3(C(Pint) numsets, C(Ppoint_list3 *) sets)
  79. PreANSI(Pint numsets)
  80. PreANSI(Ppoint_list3 *sets)
  81. /*
  82. ** \parambegin
  83. ** \param{Pint}{numsets}{number of point sets}{IN}
  84. ** \param{Ppoint\_list3 *}{sets}{list of point sets}{IN}
  85. ** \paramend 
  86. ** \blurb{This function creates a FILL AREA SET3 output primitive
  87. ** and works for both SunPHIGS and DEC PHIGS.}
  88. */
  89. {
  90.   Ppoint_list_list3 ptlist;
  91.  
  92.   ptlist.num_point_lists = numsets;
  93.   ptlist.point_lists = sets;
  94.   pfill_area_set3(&ptlist);
  95. }  /* ptk_fillareaset3 */
  96.  
  97. /*--------------------------------------------------------------------------*/
  98.  
  99. /*function:external*/
  100. extern void ptk_inqtextextent(C(Pint) wstype, C(Pint) font, C(char *) str,
  101.                               C(Pint *) err, C(Prect *) rect)
  102. PreANSI(Pint wstype)
  103. PreANSI(Pint font)
  104. PreANSI(char *str)
  105. PreANSI(Pint *err)
  106. PreANSI(Prect *rect)
  107. /*
  108. ** \parambegin
  109. ** \param{Pint}{wstype}{workstation type}{IN}
  110. ** \param{Pint}{font}{text font}{IN}
  111. ** \param{char *}{str}{character string}{IN}
  112. ** \param{Pint *}{error}{error indicator}{OUT}
  113. ** \param{Prect *}{rect}{text rectangle}{OUT}
  114. ** \paramend 
  115. ** \blurb{This function simulates the INQUIRE TEXT EXTENT
  116. ** function for HP PHIGS.}
  117. */
  118. {
  119.   switch (font)
  120.   {
  121.     case 1:
  122.       rect->p = ptk_point(0.0, 0.0);
  123.       rect->q = ptk_point(0.01 * strlen(str), 0.01);
  124.       break;
  125.   };
  126. }  /* ptk_inqtextextent */
  127.  
  128. /*--------------------------------------------------------------------------*/
  129.  
  130. /*function:external*/
  131. extern void ptk_inqcurelemtypesizecontent(C(Pstore) store, 
  132.             C(Pint *) error, C(ptkselcontent *) elcontent)
  133. PreANSI(Pstore store)
  134. PreANSI(Pint *error)
  135. PreANSI(ptkselcontent *elcontent)
  136. /*
  137. ** \parambegin
  138. ** \param{Pstore}{store}{data buffer}{OUT}
  139. ** \param{Pint *}{error}{error indicator}{OUT}
  140. ** \param{ptkselcontent *}{elcontent}{element content data record}{OUT}
  141. ** \paramend 
  142. ** \blurb{This function may be used to obtain the type, size and
  143. ** contents of the current element. The data buffer is used to store
  144. ** the element contents data and is allocated by the function. The
  145. ** buffer should be deallocated by the application when the element
  146. ** data is no longer required. This function works with both SunPHIGS
  147. ** and DEC PHIGS.}
  148. */
  149. {
  150.   size_t size;
  151.   Pint bufsize;
  152.  
  153.   pinq_cur_elem_type_size(error, &elcontent->eltype, &size);
  154.   if ((*error != 0) || (elcontent->eltype == PELEM_NIL))
  155.     return;
  156.   else
  157.     pinq_cur_elem_content(store, error, &elcontent->eldata);
  158. }  /* ptk_inqcurelemtypesizecontent */
  159.  
  160. /*--------------------------------------------------------------------------*/
  161.  
  162. /*function:external*/
  163. extern void ptk_inqcurelemtype(C(Pint *) error, C(Pelem_type *) eltype)
  164. PreANSI(Pint *error)
  165. PreANSI(Pelem_type *eltype)
  166. /*
  167. ** \parambegin
  168. ** \param{Pint *}{error}{error indicator}{OUT}
  169. ** \param{Pelem\_type *}{eltype}{element type}{OUT}
  170. ** \paramend 
  171. ** \blurb{This function may be used to obtain the current element type
  172. ** and works for both SunPHIGS and DEC PHIGS.}
  173. */
  174. {
  175.   size_t size;
  176.  
  177.   pinq_cur_elem_type_size(error, eltype, &size);
  178. }  /* ptk_inqcurelemtype */
  179.  
  180. /*--------------------------------------------------------------------------*/
  181.  
  182. /*function:external*/
  183. extern void ptk_inqelemtypesizecontent(C(Pint) stid, C(Pint) elemid, 
  184.             C(Pstore) store, C(Pint *) error,
  185.             C(ptkselcontent *) elcontent)
  186. PreANSI(Pint stid)
  187. PreANSI(Pint elemid)
  188. PreANSI(Pstore store)
  189. PreANSI(Pint *error)
  190. PreANSI(ptkselcontent *elcontent)
  191. /*
  192. ** \parambegin
  193. ** \param{Pint}{stid}{structure identifier}{IN}
  194. ** \param{Pint}{elemid}{element number}{IN}
  195. ** \param{Pstore}{store}{data buffer}{OUT}
  196. ** \param{Pint *}{error}{error indicator}{OUT}
  197. ** \param{ptkselcontent *}{elcontent}{element content data record}{OUT}
  198. ** \paramend 
  199. ** \blurb{This function may be used to obtain the type, size and
  200. ** contents of element {\tt elemid} in structure {\tt stid}. 
  201. ** The data buffer is used to store
  202. ** the element contents data and is allocated by the function. The
  203. ** buffer should be deallocated by the application when the element
  204. ** data is no longer required. This function works with both SunPHIGS
  205. ** and DEC PHIGS.}
  206. */
  207. {
  208.   size_t size;
  209.   Pint bufsize;
  210.  
  211.   pinq_elem_type_size(stid, elemid, error, &elcontent->eltype, &size);
  212.   if ((*error != 0) || (elcontent->eltype == PELEM_NIL))
  213.     return;
  214.   else
  215.     pinq_elem_content(stid, elemid, store, error, &elcontent->eldata);
  216. }  /* ptk_inqelemtypesizecontent */
  217.  
  218. /*--------------------------------------------------------------------------*/
  219.  
  220. /*function:external*/
  221. extern void ptk_inqelemtype(C(Pint) stid, C(Pint) elemid, C(Pint *) error, 
  222.                             C(Pelem_type *) eltype)
  223. PreANSI(Pint stid)
  224. PreANSI(Pint elemid)
  225. PreANSI(Pint *error)
  226. PreANSI(Pelem_type *eltype)
  227. /*
  228. ** \parambegin
  229. ** \param{Pint}{stid}{structure identifier}{IN}
  230. ** \param{Pint}{elemid}{element number}{IN}
  231. ** \param{Pint *}{error}{error indicator}{OUT}
  232. ** \param{Pelem\_type *}{eltype}{element type}{OUT}
  233. ** \paramend 
  234. ** \blurb{This function may be used to obtain the element type of
  235. ** element {\tt elemid} in structure {\tt stid}
  236. ** and works for both SunPHIGS and DEC PHIGS.}
  237. */
  238. {
  239.   size_t size;
  240.  
  241.   pinq_elem_type_size(stid, elemid, error, eltype, &size);
  242. }  /* ptk_inqelemtype */
  243.  
  244. /*--------------------------------------------------------------------------*/
  245.  
  246. /*function:external*/
  247. extern void ptk_pscale(C(Ppoint *) scalept, C(Pint *) err, C(Pmatrix) mat)
  248. PreANSI(Ppoint *scalept)
  249. PreANSI(Pint *err)
  250. PreANSI(Pmatrix mat)
  251. /*
  252. ** \parambegin
  253. ** \param{Ppoint *}{scalept}{scale vector}{IN}
  254. ** \param{Pint *}{err}{error indicator}{OUT}
  255. ** \param{Pmatrix}{mat}{3x3 matrix}{OUT}
  256. ** \paramend
  257. ** \blurb{This function performs the SCALE function using a {\tt Ppoint}
  258. ** datatype instead of {\tt Pvec}.}
  259. */
  260. {
  261.   Pvec vec;
  262.   
  263.   vec = ptk_vector(scalept->x, scalept->y);
  264.   pscale(&vec, err, mat);
  265. }  /* ptk_pscale */
  266.  
  267. /*--------------------------------------------------------------------------*/
  268.  
  269. /*function:external*/
  270. extern void ptk_pscale3(C(Ppoint3 *) scalept, C(Pint *) err, C(Pmatrix3) mat)
  271. PreANSI(Ppoint3 *scalept)
  272. PreANSI(Pint *err)
  273. PreANSI(Pmatrix3 mat)
  274. /*
  275. ** \parambegin
  276. ** \param{Ppoint3 *}{scalept}{scale vector}{IN}
  277. ** \param{Pint *}{err}{error indicator}{OUT}
  278. ** \param{Pmatrix3}{mat}{4x4 matrix}{OUT}
  279. ** \paramend
  280. ** \blurb{This function performs the SCALE3 function using a {\tt Ppoint3}
  281. ** datatype instead of {\tt Pvec3}.}
  282. */
  283. {
  284.   Pvec3 vec;
  285.   
  286.   vec = ptk_vector3(scalept->x, scalept->y, scalept->z);
  287.   pscale3(&vec, err, mat);
  288. }  /* ptk_pscale3 */
  289.  
  290. /*--------------------------------------------------------------------------*/
  291.  
  292. /*function:external*/
  293. extern void ptk_psetcharup(C(Ppoint *) pt)
  294. PreANSI(Ppoint *pt)
  295. /*
  296. ** \parambegin
  297. ** \param{Ppoint *}{pt}{character up vector}{IN}
  298. ** \paramend
  299. ** \blurb{This function performs the SET CHARACTER UP VECTOR function 
  300. ** using a {\tt Ppoint} datatype instead of {\tt Pvec}.}
  301. */
  302. {
  303.   Pvec vec;
  304.   
  305.   vec = ptk_vector(pt->x, pt->y);
  306.   pset_char_up_vec(&vec);
  307. }  /* ptk_psetcharup */
  308.  
  309. /*--------------------------------------------------------------------------*/
  310.  
  311. /*function:external*/
  312. extern void ptk_psetannotationcharup(C(Ppoint *) pt)
  313. PreANSI(Ppoint *pt)
  314. /*
  315. ** \parambegin
  316. ** \param{Ppoint *}{pt}{annotation character up vector}{IN}
  317. ** \paramend
  318. ** \blurb{This function performs the SET ANNOTATION CHARACTER UP VECTOR 
  319. ** function using a {\tt Ppoint} datatype instead of {\tt Pvec}.}
  320. */
  321. {
  322.   Pvec vec;
  323.   
  324.   vec = ptk_vector(pt->x, pt->y);
  325.   pset_anno_char_up_vec(&vec);
  326. }  /* ptk_psetannotationcharup */
  327.  
  328. /*--------------------------------------------------------------------------*/
  329.  
  330. /*function:external*/
  331. extern void ptk_ptranslate(C(Ppoint *) tranpt, C(Pint *) err, C(Pmatrix) mat)
  332. PreANSI(Ppoint *tranpt)
  333. PreANSI(Pint *err)
  334. PreANSI(Pmatrix mat)
  335. /*
  336. ** \parambegin
  337. ** \param{Ppoint *}{tranpt}{translation vector}{IN}
  338. ** \param{Pint *}{err}{error indicator}{OUT}
  339. ** \param{Pmatrix}{mat}{3x3 matrix}{OUT}
  340. ** \paramend
  341. ** \blurb{This function performs the TRANSLATE function using a {\tt Ppoint}
  342. ** datatype instead of {\tt Pvec}.}
  343. */
  344. {
  345.   Pvec vec;
  346.   
  347.   vec = ptk_vector(tranpt->x, tranpt->y);
  348.   ptranslate(&vec, err, mat);
  349. }  /* ptk_ptranslate */
  350.  
  351. /*--------------------------------------------------------------------------*/
  352.  
  353. /*function:external*/
  354. extern void ptk_ptranslate3(C(Ppoint3 *) tranpt, C(Pint *) err,
  355.                             C(Pmatrix3) mat)
  356. PreANSI(Ppoint3 *tranpt)
  357. PreANSI(Pint *err)
  358. PreANSI(Pmatrix3 mat)
  359. /*
  360. ** \parambegin
  361. ** \param{Ppoint3 *}{tranpt}{translation vector}{IN}
  362. ** \param{Pint *}{err}{error indicator}{OUT}
  363. ** \param{Pmatrix3}{mat}{4x4 matrix}{OUT}
  364. ** \paramend
  365. ** \blurb{This function performs the TRANSLATE3 function using a {\tt Ppoint3}
  366. ** datatype instead of {\tt Pvec3}.}
  367. */
  368. {
  369.   Pvec3 vec;
  370.   
  371.   vec = ptk_vector3(tranpt->x, tranpt->y, tranpt->z);
  372.   ptranslate3(&vec, err, mat);
  373. }  /* ptk_ptranslate3 */
  374.  
  375. /*--------------------------------------------------------------------------*/
  376.  
  377. /*function:external*/
  378. extern void ptk_pbuildtran(C(Ppoint *) pt, C(Ppoint *) shift, 
  379.                            C(Pfloat) angle, C(Ppoint *) scale,
  380.                            C(Pint *) err, C(Pmatrix) mat)
  381. PreANSI(Ppoint *pt)
  382. PreANSI(Ppoint *shift)
  383. PreANSI(Pfloat angle)
  384. PreANSI(Ppoint *scale)
  385. PreANSI(Pint *err)
  386. PreANSI(Pmatrix mat)
  387. /*
  388. ** \parambegin
  389. ** \param{Ppoint *}{pt}{fixed point}{IN}
  390. ** \param{Ppoint *}{shift}{shift vector}{IN}
  391. ** \param{Pfloat}{angle}{rotation angle}{IN}
  392. ** \param{Ppoint *}{scale}{scale vector}{IN}
  393. ** \param{Pint *}{err}{error indicator}{OUT}
  394. ** \param{Pmatrix}{mat}{3x3 matrix}{OUT}
  395. ** \paramend
  396. ** \blurb{This function performs the BUILD TRANSFORMATION MATRIX
  397. ** function using the {\tt Ppoint} datatype instead of {\tt Pvec}.}
  398. */
  399. {
  400.   Pvec vec1, vec2;
  401.   
  402.   vec1 = ptk_vector(shift->x, shift->y);
  403.   vec2 = ptk_vector(scale->x, scale->y);
  404.   pbuild_tran_matrix(pt, &vec1, angle, &vec2, err, mat);
  405. }  /* ptk_pbuildtran */
  406.  
  407. /*--------------------------------------------------------------------------*/
  408.  
  409. /*function:external*/
  410. extern void ptk_pbuildtran3(C(Ppoint3 *) pt, C(Ppoint3 *) shift, 
  411.       C(Pfloat) xangle, C(Pfloat) yangle, C(Pfloat) zangle, 
  412.       C(Ppoint3 *) scale, C(Pint *) err, C(Pmatrix3) mat)
  413. PreANSI(Ppoint3 *pt)
  414. PreANSI(Ppoint3 *shift)
  415. PreANSI(Pfloat xangle)
  416. PreANSI(Pfloat yangle)
  417. PreANSI(Pfloat zangle)
  418. PreANSI(Ppoint3 *scale)
  419. PreANSI(Pint *err)
  420. PreANSI(Pmatrix3 mat)
  421. /*
  422. ** \parambegin
  423. ** \param{Ppoint3 *}{pt}{fixed point}{IN}
  424. ** \param{Ppoint3 *}{shift}{shift vector}{IN}
  425. ** \param{Pfloat}{xangle}{x rotation angle}{IN}
  426. ** \param{Pfloat}{yangle}{y rotation angle}{IN}
  427. ** \param{Pfloat}{zangle}{z rotation angle}{IN}
  428. ** \param{Ppoint3 *}{scale}{scale vector}{IN}
  429. ** \param{Pint *}{err}{error indicator}{OUT}
  430. ** \param{Pmatrix3}{mat}{4x4 matrix}{OUT}
  431. ** \paramend
  432. ** \blurb{This function performs the BUILD TRANSFORMATION MATRIX3
  433. ** function using the {\tt Ppoint3} datatype instead of {\tt Pvec3}.}
  434. */
  435. {
  436.   Pvec3 vec1, vec2;
  437.   
  438.   vec1 = ptk_vector3(shift->x, shift->y, shift->z);
  439.   vec2 = ptk_vector3(scale->x, scale->y, scale->z);
  440.   pbuild_tran_matrix(pt, &vec1, xangle, yangle, zangle, &vec2, err, mat);
  441. }  /* ptk_pbuildtran3 */
  442.  
  443. /*--------------------------------------------------------------------------*/
  444.  
  445. /*function:external*/
  446. extern void ptk_pcomposetran(C(Pmatrix) mat, C(Ppoint *) pt, 
  447.                  C(Ppoint *) shift, C(Pfloat) angle, C(Ppoint *) scale,
  448.                  C(Pint *) err, C(Pmatrix) result)
  449. PreANSI(Pmatrix mat)
  450. PreANSI(Ppoint *pt)
  451. PreANSI(Ppoint *shift)
  452. PreANSI(Pfloat angle)
  453. PreANSI(Ppoint *scale)
  454. PreANSI(Pint *err)
  455. PreANSI(Pmatrix result)
  456. /*
  457. ** \parambegin
  458. ** \param{Pmatrix}{mat}{3x3 matrix}{IN}
  459. ** \param{Ppoint *}{pt}{fixed point}{IN}
  460. ** \param{Ppoint *}{shift}{shift vector}{IN}
  461. ** \param{Pfloat}{angle}{rotation angle}{IN}
  462. ** \param{Ppoint *}{scale}{scale vector}{IN}
  463. ** \param{Pint *}{err}{error indicator}{OUT}
  464. ** \param{Pmatrix}{result}{3x3 matrix}{OUT}
  465. ** \paramend
  466. ** \blurb{This function performs the COMPOSE TRANSFORMATION MATRIX
  467. ** function using the {\tt Ppoint} datatype instead of {\tt Pvec}.}
  468. */
  469. {
  470.   Pvec vec1, vec2;
  471.   
  472.   vec1 = ptk_vector(shift->x, shift->y);
  473.   vec2 = ptk_vector(scale->x, scale->y);
  474.   pbuild_tran_matrix(mat, pt, &vec1, angle, &vec2, err, result);
  475. }  /* ptk_pcomposetran */
  476.  
  477. /*--------------------------------------------------------------------------*/
  478.  
  479. /*function:external*/
  480. extern void ptk_pcomposetran3(C(Pmatrix3) mat, C(Ppoint3 *) pt, 
  481.      C(Ppoint3 *) shift, C(Pfloat) xangle, C(Pfloat) yangle, 
  482.      C(Pfloat) zangle, C(Ppoint3 *) scale, C(Pint *) err, C(Pmatrix3) result)
  483. PreANSI(Pmatrix3 mat)
  484. PreANSI(Ppoint3 *pt)
  485. PreANSI(Ppoint3 *shift)
  486. PreANSI(Pfloat xangle)
  487. PreANSI(Pfloat yangle)
  488. PreANSI(Pfloat zangle)
  489. PreANSI(Ppoint3 *scale)
  490. PreANSI(Pint *err)
  491. PreANSI(Pmatrix3 result)
  492. /*
  493. ** \parambegin
  494. ** \param{Pmatrix3}{mat}{4x4 matrix}{OUT}
  495. ** \param{Ppoint3 *}{pt}{fixed point}{IN}
  496. ** \param{Ppoint3 *}{shift}{shift vector}{IN}
  497. ** \param{Pfloat}{xangle}{x rotation angle}{IN}
  498. ** \param{Pfloat}{yangle}{y rotation angle}{IN}
  499. ** \param{Pfloat}{zangle}{z rotation angle}{IN}
  500. ** \param{Ppoint3 *}{scale}{scale vector}{IN}
  501. ** \param{Pint *}{err}{error indicator}{OUT}
  502. ** \param{Pmatrix3}{result}{4x4 matrix}{OUT}
  503. ** \paramend
  504. ** \blurb{This function performs the COMPOSE TRANSFORMATION MATRIX3
  505. ** function using the {\tt Ppoint3} datatype instead of {\tt Pvec3}.}
  506. */
  507. {
  508.   Pvec3 vec1, vec2;
  509.   
  510.   vec1 = ptk_vector3(shift->x, shift->y, shift->z);
  511.   vec2 = ptk_vector3(scale->x, scale->y, scale->z);
  512.   pbuild_tran_matrix(mat, pt, &vec1, xangle, yangle, zangle, &vec2, err, result);
  513. }  /* ptk_pcomposetran3 */
  514.  
  515. /*--------------------------------------------------------------------------*/
  516.  
  517. /*function:external*/
  518. extern void ptk_pevalvieworientationmatrix(C(Ppoint *) vrp, C(Ppoint *) vup, 
  519.                   C(Pint *) err, C(Pmatrix) mat)
  520. PreANSI(Ppoint *vrp)
  521. PreANSI(Ppoint *vup)
  522. PreANSI(Pint *err)
  523. PreANSI(Pmatrix mat)
  524. /*
  525. ** \parambegin
  526. ** \param{Ppoint *}{vrp}{view reference point}{IN}
  527. ** \param{Ppoint *}{vup}{view up vector}{IN}
  528. ** \param{Pint *}{err}{error indicator}{OUT}
  529. ** \param{Pmatrix}{mat}{3x3 matrix}{OUT}
  530. ** \paramend
  531. ** \blurb{This function performs the EVALUATE VIEW ORIENTATION MATRIX
  532. ** function using the {\tt Ppoint3} datatype instead of {\tt Pvec3}.}
  533. */
  534. {
  535.   Pvec vec;
  536.   
  537.   vec = ptk_vector(vup->x, vup->y);
  538.   peval_view_ori_matrix(vrp, &vec, err, mat);
  539. }  /* ptk_pevalvieworientationmatrix */
  540.  
  541. /*--------------------------------------------------------------------------*/
  542.  
  543. /*function:external*/
  544. extern void ptk_pevalvieworientationmatrix3(C(Ppoint3 *) vrp, 
  545.                   C(Ppoint3 *) vpn, C(Ppoint3 *) vup, C(Pint *) err, 
  546.                   C(Pmatrix3) mat)
  547. PreANSI(Ppoint3 *vrp)
  548. PreANSI(Ppoint3 *vpn)
  549. PreANSI(Ppoint3 *vup)
  550. PreANSI(Pint *err)
  551. PreANSI(Pmatrix3 mat)
  552. /*
  553. ** \parambegin
  554. ** \param{Ppoint3 *}{vrp}{view reference point}{IN}
  555. ** \param{Ppoint3 *}{vup}{view up vector}{IN}
  556. ** \param{Ppoint3 *}{vpn}{view plane normal}{IN}
  557. ** \param{Pint *}{err}{error indicator}{OUT}
  558. ** \param{Pmatrix}{mat}{3x3 matrix}{OUT}
  559. ** \paramend
  560. ** \blurb{This function performs the EVALUATE VIEW ORIENTATION MATRIX3
  561. ** function using the {\tt Ppoint3} datatype instead of {\tt Pvec3}.}
  562. */
  563. {
  564.   Pvec3 vec1, vec2;
  565.   
  566.   vec1 = ptk_vector3(vpn->x, vpn->y, vpn->z);
  567.   vec2 = ptk_vector3(vup->x, vup->y, vup->z);
  568.   peval_view_ori_matrix3(vrp, &vec1, &vec2, err, mat);
  569. }  /* ptk_pevalvieworientationmatrix3 */
  570.  
  571. /*--------------------------------------------------------------------------*/
  572.  
  573. extern ptkboolean pt3inlimit3(C(Ppoint3 *) pt3, C(Plimit3 *) limit3)
  574. PreANSI(Ppoint3 *pt3)
  575. PreANSI(Plimit3 *limit3)
  576. {
  577.   return ((pt3->x >= limit3->x_min) && (pt3->x <= limit3->x_max)
  578.        && (pt3->y >= limit3->y_min) && (pt3->y <= limit3->y_max)
  579.        && (pt3->z >= limit3->z_min) && (pt3->z <= limit3->z_max));
  580. }
  581.  
  582. /*--------------------------------------------------------------------------*/
  583.  
  584. extern ptkboolean ptinlimit3(C(Ppoint *) pt, C(Plimit3 *) limit3)
  585. PreANSI(Ppoint *pt)
  586. PreANSI(Plimit3 *limit3)
  587. {
  588.   return ((pt->x >= limit3->x_min) && (pt->x <= limit3->x_max)
  589.        && (pt->y >= limit3->y_min) && (pt->y <= limit3->y_max)
  590.        && (0.0 >= limit3->z_min) && (0.0 <= limit3->z_max));
  591. }
  592.  
  593. /*--------------------------------------------------------------------------*/
  594.  
  595. extern Pint instrlist(C(char **) strlist, C(Pint) lenlist, C(char *) str) 
  596. PreANSI(char **strlist)
  597. PreANSI(Pint lenlist)
  598. PreANSI(char *str)
  599. /*
  600. ** description: searches list of strings for given string.
  601. ** input params: strlist - pointer to string list.
  602. ** lenlist - length of string list.
  603. ** str - string to search.
  604. ** output params: none.
  605. ** return value: index of found string, -1 if not found.
  606. ** special notes: 
  607. */
  608. {
  609.   ptkboolean found;
  610.   Pint    i;
  611.  
  612.   found = FALSE;
  613.   i = 0;
  614.   while ((found == FALSE) && (i < lenlist))
  615.   {
  616.     if (strcmp(strlist[i], str) == 0)
  617.       found = TRUE;
  618.     else
  619.       i++;
  620.   }
  621.   if (found == FALSE)
  622.     return -1;
  623.   else
  624.     return i;
  625. }  /* instrlist */
  626.  
  627. /*--------------------------------------------------------------------------*/
  628.  
  629. extern Pint inintlst(C(Pint) n, C(Pint_list *) list)
  630. PreANSI(Pint n)
  631. PreANSI(Pint_list *list)
  632. /*
  633. ** description: search for integer in integer list. 
  634. ** input params: n - integer to search for.
  635. ** list - list of integers to search in.
  636. ** output params: none.
  637. ** return value: TRUE if integer in list, otherwise FALSE.
  638. */
  639. {
  640.   Pint i;
  641.   ptkboolean found;
  642.  
  643.   i = 0;
  644.   found = FALSE;
  645.   while (!found && (i < list->num_ints)) 
  646.   {
  647.     if (list->ints[i] == n)
  648.       found = TRUE;
  649.     else
  650.       i++;
  651.   }
  652.   if (found == FALSE)
  653.     return -1;
  654.   else
  655.     return i;
  656. }  /* inintlst */
  657.  
  658. /*--------------------------------------------------------------------------*/
  659.  
  660. extern void addtointlst(C(Pint) addint, C(Pint_list *) list)
  661. PreANSI(Pint addint)
  662. PreANSI(Pint_list *list)
  663. {
  664.   if (inintlst(addint, list) == -1)
  665.   {
  666.     (list->num_ints)++;
  667.     list->ints[list->num_ints - 1] = addint;
  668.   }
  669. }  /* addtointlst */
  670.  
  671. /*--------------------------------------------------------------------------*/
  672.  
  673. extern void removefromintlst(C(Pint) remint, C(Pint_list *) list)
  674. PreANSI(Pint remint)
  675. PreANSI(Pint_list *list)
  676. {
  677.   Pint j, ind;
  678.  
  679.   if ((ind = inintlst(remint, list)) != -1)
  680.   {
  681.     for (j = ind; j < list->num_ints - 1; j++)
  682.       list->ints[j] = list->ints[j + 1];
  683.     (list->num_ints)--;
  684.   }
  685. }  /* removefromintlst */
  686.  
  687. /*--------------------------------------------------------------------------*/
  688.  
  689. extern void strupper(C(char *) str)
  690. PreANSI(char *str)
  691. {
  692.   Pint ind, strlength;
  693.   
  694.   strlength = strlen(str);
  695.   for (ind = 0; ind < strlength; ind++) 
  696.   {
  697.     if (islower(str[ind]))
  698.       str[ind] = str[ind] + ('A' - 'a');
  699.   }
  700. }  /* strupper */
  701.  
  702. /*--------------------------------------------------------------------------*/
  703.  
  704. extern void strlower(C(char *) str)
  705. PreANSI(char *str)
  706. {
  707.   Pint ind, strlength;
  708.  
  709.   strlength = strlen(str);
  710.   for (ind = 0; ind < strlength; ind++) 
  711.   {
  712.     if (isupper(str[ind]))
  713.       str[ind] = str[ind] - ('A' - 'a');
  714.   }
  715. }  /* strlower */
  716.  
  717. /*--------------------------------------------------------------------------*/
  718.  
  719. extern Pint stringlength(C(char *)str)
  720. PreANSI(char *str)
  721. /*
  722. ** description: returns length of string up to first ' '(space), '\n' or '\0' 
  723. ** character.
  724. ** input params: str - string to find length of.
  725. ** return value: length of string.
  726. ** special notes: The hashstrings algorithm does not permit strings with
  727. ** spaces, hence the search for the first space character. The C library
  728. ** routine `strlen' assumes there is a `\0' character terminating the string,
  729. ** however it is safer to look for a `\n' character aswell.
  730. */
  731. {
  732.   ptkboolean charfound;
  733.   Pint ind;
  734.  
  735.   ind = 0;
  736.   charfound = FALSE;
  737.   while (!charfound) 
  738.   {
  739.     if (str[ind] == ' ' || str[ind] == '\n' || str[ind] == '\0')
  740.       charfound = TRUE;
  741.     else
  742.       ind++;
  743.   }
  744.   return ind;
  745. }  /* stringlength */
  746.  
  747. /*--------------------------------------------------------------------------*/
  748.  
  749. /* end of misc.c */
  750.